package com.gxan.service.impl;

import com.gxan.common.LayuiRepResult;
import com.gxan.dao.StandardDao;
import com.gxan.dao.impl.StandardDaoImpl;
import com.gxan.pojo.SalStandard;
import com.gxan.service.StandardService;

import java.sql.SQLException;
import java.util.List;

public class StandardServiceImpl implements StandardService {
    //定义成员变量
    private StandardDao standardDao = new StandardDaoImpl();
    /**
     * 查询所有小区数据-分页
     *
     * @param page  当前页码数
     * @param limit 每页显示的条数
     * @return
     */
    @Override
    public LayuiRepResult salFindAll(Integer page, Integer limit) {
        try {
            Integer offset = (page - 1) * limit;
            Integer rows = limit;
            //查询数据
            List<SalStandard> salStandardList = standardDao.queryStandardList(offset, rows);
            //统计总条数
            Integer count = standardDao.countStandard();
            //返回结果
            return LayuiRepResult.success(count,salStandardList);
        }catch (Exception e){
            return LayuiRepResult.error();
        }
    }
    /**
     * 添加薪酬标准
     * @param salStandard
     * @return
     * @throws SQLException
     */
    @Override
    public int addStandard(SalStandard salStandard) throws SQLException {
            int result = standardDao.addStandardList((salStandard));
            return result;
    }
    /**
     * 修改
     * @param salStandard
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStandard(SalStandard salStandard) throws SQLException {
        return standardDao.updateStandard(salStandard);
    }
    /**
     * 复核
     * @param salStandard
     * @return
     * @throws SQLException
     */
    @Override
    public int reviewStandard(SalStandard salStandard) throws SQLException {
        return standardDao.reviewStandard(salStandard);

    }
    /**
     * 变更
     * @param salStandard
     * @return
     * @throws SQLException
     */
    @Override
    public int changeStandard(SalStandard salStandard) throws SQLException {
        return standardDao.changeStandard(salStandard);
    }
    /**
     * 明细
     * @param salStandard
     * @return
     * @throws SQLException
     */
    @Override
    public int detailsStandard(SalStandard salStandard) throws SQLException {
        return standardDao.detailsStandard(salStandard);
    }

    /**
     * 按编号删除记录
     * @param sal_standard_code
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteStandard(String sal_standard_code) throws SQLException {
        return standardDao.deleteStandard(sal_standard_code);

    }

    /**
     * 搜索
     * @param page
     * @param limit
     * @param review_time
     * @return
     */
    @Override
    public List<SalStandard> searchStandard(Integer page, Integer limit,String sal_standard_name ,Integer review_time) throws SQLException {
        Integer offset = (page - 1) * limit;
        Integer rows = limit;
        return standardDao.searchStandard(offset,rows,sal_standard_name,review_time);
    }

    @Override
    public int countSearchStandard(String sal_standard_name,Integer review_time) throws SQLException {
        return standardDao.countSearchStandard(sal_standard_name,review_time);
    }


}

